using huqiang.Core.HGUI;
using huqiang.UIModel;
using UnityEngine;

public class LoginPage : UIPage
{
    LoginPageView view;
    public override void Initial(UIElement parent, object dat = null)
    {
        base.Initial(parent, dat);
        LoadUI("LoginPage");
        view = new LoginPageView();
        InitialEvent();
    }
    void InitialEvent()
    {
        Keygen.Generate();
        view.MachineCode.text = Keygen.MachineCode;
        Debug.Log(Keygen.GetPass("1234567890abcdefabcdef0987654321"));
        view.Copy.Click = (o, e) =>
        {
            GUIUtility.systemCopyBuffer = view.MachineCode.text;
        };
        view.Paste.Click = (o, e) =>
        {
            view.RegCode.InputString = GUIUtility.systemCopyBuffer;
        };
        view.Reg.Click=(o,e) =>
        {
            //if (view.RegCode.InputString == null || view.RegCode.InputString == "")
            //    return;
            //if (Keygen.ComparePass(view.RegCode.InputString, "1234567890abcdefabcdef0987654321"))
            //{
            //    Keygen.SavePass(view.RegCode.InputString);
            //    LoadPage<ChangeTextBooks>();
            //}
            //else view.Tips.activeSelf = true;

            LoadPage<ChangeTextBooks>();
        };
    }
}